home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / libs / x / xview / xview3.004 / xview3 / usr / openwin / include / pixrect / memvar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-30  |  5.0 KB  |  162 lines

  1. /* @(#)memvar.h 1.45 89/12/13 SMI */
  2.  
  3. /*
  4.  * Copyright 1986-1989 Sun Microsystems, Inc.
  5.  */
  6.  
  7. #ifndef    memvar_DEFINED
  8. #define    memvar_DEFINED
  9.  
  10. /*
  11.  * A memory pixrect is a special type of pixrect.  Its image resides in
  12.  * memory, in a publicly known format permitting more direct access to the
  13.  * image than possible with the general pixrectops.
  14.  *
  15.  * In the memory pixrect the image is stored in consecutive memory locations,
  16.  * across the row from left to right, and then from top to bottom.  Each row
  17.  * is padded to a 16-bit or 32-bit boundary (for details refer to the Pixrect
  18.  * Reference Manual).
  19.  *
  20.  * The depth of a pixel is the number of bits required to represent it.
  21.  * Pixels are placed in consecutive fields of width the depth of each pixel,
  22.  * with placement being independent of word or byte boundaries.
  23.  */
  24. struct mpr_data {
  25.     int    md_linebytes;    /* number of bytes from one line to next */
  26.     short    *md_image;    /* word address */
  27.     struct    pr_pos md_offset;
  28.     short    md_primary;
  29.     short    md_flags;    /* Flag bits, see below */
  30. };
  31.  
  32. /* pixrect data for memory pixrect with plane mask (MP_PLANEMASK set) */
  33. struct mprp_data {
  34.         struct mpr_data    mpr;
  35.         int        planes;
  36. };
  37.  
  38. #define mpr_d(pr)    ((struct mpr_data *) (pr)->pr_data)
  39. #define mprp_d(pr)    ((struct mprp_data *) (pr)->pr_data)
  40.  
  41. /* md_flags bits definitions */
  42.  
  43. #define MP_REVERSEVIDEO    1    /* Pixrect is reverse video */
  44.                 /* (should only be set if pr_depth = 1) */
  45. #define MP_DISPLAY    2    /* Pixrect is a frame buffer device */
  46. #define MP_PLANEMASK    4    /* Pixrect has a plane mask */
  47.                 /* (should only be set if pr_depth > 1) */
  48. #ifdef i386
  49. #define MP_I386        8    /* Pixrect is for 386 architecture */
  50. #define MP_STATIC       16    /* Pixrect is a static pixrect */
  51. #endif i386
  52. #define    MP_FONT        32    /* Pixrect is a part of a Pixfont */
  53.                 /* (hint to pr_batchrop) */
  54.  
  55. /* 
  56.  * Each line (row) of the pixrect is padded to be a multiple
  57.  * of this many bits 
  58.  */
  59. #define MPR_LINEBITPAD    16
  60.  
  61. #define    mpr_linebytes(x, depth)                        \
  62.     ( ((pr_product(x, depth) + (MPR_LINEBITPAD-1)) >> 3) &~ 1)
  63. #define mpr_prlinebytes(mpr)                        \
  64.     mpr_linebytes((mpr)->pr_size.x, (mpr)->pr_depth)
  65. #define    mpr_mdlinebytes(mpr)                        \
  66.     (mpr_d(mpr)->md_linebytes)
  67.  
  68. #define mprd_addr(mprd, xo, yo)                        \
  69.     ((short *)(                            \
  70.         (int)(mprd)->md_image                                       \
  71.         + pr_product((mprd)->md_linebytes,(mprd)->md_offset.y+(yo)) \
  72.         + (((mprd)->md_offset.x+(xo)) >> 3) &~ 1))
  73.  
  74. #define mprd8_addr(mprd, xo, yo, d)                    \
  75.      ((u_char *)(                            \
  76.          (int)(mprd)->md_image                    \
  77.         + pr_product((mprd)->md_linebytes,(mprd)->md_offset.y+(yo)) \
  78.         + (pr_product((mprd)->md_offset.x+(xo), (d)) >> 3) )  )
  79.  
  80. #define    mprd_skew(mprd, xo, yo)                        \
  81.     (((mprd)->md_offset.x + (xo)) & 15)
  82.  
  83. #define    mprs_addr(mprs)        _mprs_addr((struct pr_prpos *)&(mprs))
  84. #define    mprs8_addr(mprs)    _mprs8_addr((struct pr_prpos *)&(mprs))
  85. #define    mprs_skew(mprs)        _mprs_skew((struct pr_prpos *)&(mprs))
  86.  
  87. #if !defined lint || !defined KERNEL || defined(sun2)
  88. short    *_mprs_addr();
  89. u_char    *_mprs8_addr();
  90. int    _mprs_skew();
  91. #endif
  92.  
  93. /*
  94.  * Static pixrects.  A pixrect may be created at compile time using the
  95.  * mpr_static macro as part of the static declarations of a program.  Thus
  96.  * mpr_static(cursor, 16, 16, 1, rawcursordata);
  97.  * will declare and initialize (using rawcursordata) the storage needed
  98.  * for a pixrect that may be referred to as 'cursor' subsequently in the
  99.  * same file, or as &cursor if a pointer to that pixrect is called for rather
  100.  * than the pixrect itself.
  101.  */
  102.  
  103. /* First a pair of utility macros that allow concatenation in a fashion that
  104.  * won't annoy lint (These belong in a standard header file!):
  105.  */
  106. #ifndef    CAT
  107. # ifdef __STDC__
  108. #  define    CAT(a,b)    a ## b
  109. # else /* __STDC__ */
  110. #  undef    IDENT
  111. #  define IDENT(x)    x
  112. #  define    CAT(a,b)    IDENT(a)b
  113. # endif /* __STDC__ */
  114. #endif /* CAT */
  115.  
  116. #define mpr_static(name, w, h, d, image) \
  117.     struct mpr_data CAT(name,_data) = \
  118.         {mpr_linebytes(w,d), (short *)(image), {0, 0}, 0, 0}; \
  119.     Pixrect name = {&mem_ops, w, h, d, (caddr_t)&CAT(name,_data)}
  120.  
  121. /* static pixrect with variables declared "static" */
  122. #define    mpr_static_static(name, w, h, d, image) \
  123.     static struct mpr_data CAT(name,_data) = \
  124.         {mpr_linebytes(w,d), (short *)(image), {0, 0}, 0, 0}; \
  125.     static Pixrect name = {&mem_ops, w, h, d, (caddr_t)&CAT(name,_data)}
  126.  
  127. #ifndef NEWPIXMEM
  128. /*
  129.  * During rop calls need to determine if dst/src is something that
  130.  * mem_rop() can handle.  Use the following macro to find out.
  131.  */
  132. #define    MP_NOTMPR(pr)    ((pr)->pr_ops->pro_rop != mem_rop)
  133.  
  134. extern struct pixrectops mem_ops;
  135.  
  136. int    mem_rop();
  137. #ifndef KERNEL
  138. int    mem_stencil();
  139. int    mem_batchrop();
  140. Pixrect *mem_create();        /* General mpr create routine */
  141. Pixrect *mem_point();        /* Even more general mpr create */
  142. int    mem_destroy();
  143. int    mem_get();
  144. int    mem_put();
  145. int    mem_vector();
  146. Pixrect *mem_region();
  147. #endif KERNEL
  148. int    mem_putcolormap();
  149. int    mem_putattributes();
  150. #ifndef KERNEL
  151. int    mem_getcolormap();
  152. int    mem_getattributes();
  153. #endif KERNEL
  154.  
  155. #else /* NEWPIXMEM */
  156. #define    MP_NOTMPR(pr)    (0)
  157. extern struct pixrectops mem_ops;
  158. int    mem_destroy();
  159. #endif NEWPIXMEM
  160.  
  161. #endif    !memvar_DEFINED
  162.